<?
class Logger
{
    public static $level;
    public static $debug;
    public static $error;

    function __construct() {
    }

    function setLevel($level) {
        self::$level = $level;
    }

    function printDebug() {
        $html = "";
        $html .= self::$debug;
        return $html;
    }

    function printError() {
        $html = "";
        $html .= self::$error;
        return $html;
    }

    function log($stmt) {
        if (self::$level == "DEBUG") {
          self::$debug .= "[". date("D M j G:i:s")  ."] ". $stmt ."\n";
        }
    }

    function err($stmt) {
        if (self::$level == "DEBUG") {
          self::$debug .= "[". date("D M j G:i:s")  ."] ". $stmt ."\n";
          self::$error .= "[". date("D M j G:i:s")  ."] ". $stmt ."\n";
          $_SESSION['error'] .= $stmt."\n";
        }
    }

    function getUploadError($error) {
        $uploadErrors = array(
          0=>"There is no error, the file uploaded with success",
          1=>"The uploaded file exceeds the upload_max_filesize directive in php.ini",
          2=>"The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form",
          3=>"The uploaded file was only partially uploaded",
          //4=>"No file was uploaded",
          6=>"Missing a temporary folder",
          7=>"Failed to write file to disk",
          8=>"File upload stopped by extension"
        );
        return $uploadErrors[$error];
    }

}
?>
